#include "GameSound.h"

#define NUM_SOUNDS 4

string soundNames[NUM_SOUNDS] = {
	"../../Sounds/background.wav",
	"../../Sounds/checkmenu.wav",
	"../../Sounds/explode.wav",
	"../../Sounds/buffer.wav"
};

GameSound* GameSound::gsInst = NULL;

GameSound::GameSound(CameraNode* cam)
{
	camera = cam;
	SoundSystem::GetSoundSystem()->SetListener(camera);
	for (int i = 0; i < NUM_SOUNDS; ++i) {
		Sound::AddSound(soundNames[i]);
	}
	InsertSound(0, true);
	playDeadSound = true;
}


GameSound::~GameSound(void)
{
}

void GameSound::InsertSound(int index, bool isloop)
{
	SoundNode* sn = new SoundNode();
	sn->SetSound(Sound::GetSound(soundNames[index]));
	sn->SetLooping(isloop);
	sn->SetIsGlobal(true);
	sn->SetPriority(SOUNDPRIORTY_LOW);
	sv.push_back(sn);
}

void GameSound::UpdateSound(float msec)
{
	for (int i = 0; i < sv.size(); i++)
	{
		sv[i]->Update(msec);
	}
	SoundSystem::GetSoundSystem()->Update(msec);
}